package org.footballmanager.pandafootball.system.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.footballmanager.pandafootball.common.annotation.SystemServiceLog;
import org.footballmanager.pandafootball.common.constants.Constants;
import org.footballmanager.pandafootball.common.job.AutoBfJob;
import org.footballmanager.pandafootball.common.job.QuartzManager;
import org.footballmanager.pandafootball.common.util.DateUtils;
import org.footballmanager.pandafootball.system.dao.FootBfinfoDao;
import org.footballmanager.pandafootball.system.domain.*;
import org.footballmanager.pandafootball.system.domain.enums.BFLX;
import org.footballmanager.pandafootball.system.domain.enums.BFZT;
import org.footballmanager.pandafootball.system.domain.enums.SJZT;
import org.footballmanager.pandafootball.system.form.impl.FootBfinfoSearchForm;
import org.footballmanager.pandafootball.system.form.impl.FootYysSearchForm;
import org.footballmanager.pandafootball.system.mapper.FootBfinfoMapper;
import org.footballmanager.pandafootball.system.service.*;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.io.Serializable;
import java.util.*;

@Slf4j
@Service("footBfinfoService")
public class FootBfinfoServiceImpl extends ServiceImpl<FootBfinfo> implements FootBfinfoService {
    private static final String MYVIEW = "/hy/footBfinfo/myView";
    private static final String CANGOON = "canGoOn";
    private static final String ZHUTEAM = "zhuTeam";
    private static final String KETEAM = "keTeam";
    private static final String POWERONE = "power1";
    private static final String POWERTWO = "power2";

    @Autowired
    private FootBfinfoDao footBfinfoDao;
    @Autowired
    private FootBfinfoMapper footBfinfoMapper;
    @Autowired
    private FootUserService footUserService;
    @Autowired
    private FootUserPersonService footUserPersonService;
    @Autowired
    private FootClubService footClubService;
    @Autowired
    private FootRankService footRankService;
    @Autowired
    private FootTtService footTtService;
    @Autowired
    private FootTeamService footTeamService;
    @Autowired
    private FootZnxService footZnxService;
    @Autowired
    private FootSjService footSjService;
    @Autowired
    private FootYysService footYysService;
    @Autowired
    private FootBfDetailService footBfDetailService;
    @Autowired
    private FootBfMvpService footBfMvpService;
    @Autowired
    private FootPersonViewService footPersonViewService;
    @Autowired
    private Scheduler scheduler;

    /**
     * 删除报分记录
     *
     * @param id      主键
     * @param request 请求
     * @return 是否成功
     */
    @Override
    @Transactional
    @SystemServiceLog(description = "删除报分记录")
    public int delete(Serializable id, HttpServletRequest request) {
        FootBfinfo t = this.get(id);
        log.info("删除球队报分:" + t.toString());
        if (t.getBfzt().equals(BFZT.HAVE)) {
            if (t.getBflx().equals(BFLX.NORMAL)) {
                footClubService.deleteEncourage(t, request);
                footUserPersonService.addUseTimes(t.getQd1(), request);
                footUserPersonService.addUseTimes(t.getQd2(), request);
                footClubService.reComputeRanking(request);
            } else if (t.getBflx().equals(BFLX.GRID)) {
                footRankService.deleteEncourage(t, request);
                footRankService.reComputeRanking(request);
            } else if (t.getBflx().equals(BFLX.TOP)) {
                footTtService.deleteEncourage(t, request);
                footTtService.reComputeRanking(request);
            } else if (t.getBflx().equals(BFLX.HOTBODY)) {
                footYysService.setYysData(t, false, request);
                footYysService.addCreditByUserId(t.getQd1(), -1D, request);
                footYysService.addCreditByUserId(t.getQd2(), -2D, request);
            }
        }
        return super.delete(id, request);
    }

    /**
     * 更新所有属性
     *
     * @param t       实体类
     * @param request 请求
     * @return 是否成功
     */
    @Override
    @Transactional
    @SystemServiceLog(description = "更新所有报分记录")
    public int updateAll(FootBfinfo t, HttpServletRequest request) {
        log.info("更新球队报分:" + t.toString());
        t.setBfzt(BFZT.HAVE);
        if (t.getBflx().equals(BFLX.NORMAL)) {
            footUserPersonService.autoDeletePerson(t.getQd1(), request);
            footUserPersonService.autoDeletePerson(t.getQd2(), request);
            footClubService.addEncourage(t, request);
            footZnxService.sendZnx(t.getQd2(), t.getQd1(), "已确认常规赛比分", footTeamService.getLogoByUserid(t.getQd2()),
                    MYVIEW, request);
        } else if (t.getBflx().equals(BFLX.GRID)) {
            footRankService.addEncourage(t, request);
            footZnxService.sendZnx(t.getQd2(), t.getQd1(), "已确认排位赛比分", footTeamService.getLogoByUserid(t.getQd2()),
                    MYVIEW, request);
        } else if (t.getBflx().equals(BFLX.HOTBODY)) {
            footYysService.setYysData(t, true, request);
            footYysService.addCreditByUserId(t.getQd2(), 2D, request);
            footZnxService.sendZnx(t.getQd2(), t.getQd1(), "已确认排位赛比分", footTeamService.getLogoByUserid(t.getQd2()),
                    MYVIEW, request);
        }
        footPersonViewService.updateData(t, request);
        return super.updateAll(t, request);
    }

    /**
     * 报分报分记录
     *
     * @param t       实体类
     * @param request 请求
     * @return 是否成功
     */
    @Override
    @Transactional
    @SystemServiceLog(description = "保存报分记录")
    public int save(FootBfinfo t, HttpServletRequest request) {
        t.setBfzt(BFZT.NOT);
        if (t.getBflx().equals(BFLX.NORMAL)) {
            footZnxService.sendZnx(t.getQd1(), t.getQd2(), "请确认常规赛比赛结果",
                    null, MYVIEW, request);
        } else if (t.getBflx().equals(BFLX.GRID)) {
            footZnxService.sendZnx(t.getQd1(), t.getQd2(), "请确认排位赛比赛结果",
                    null, MYVIEW, request);
        } else if (t.getBflx().equals(BFLX.HOTBODY)) {
            footYysService.addCreditByUserId(t.getQd1(), 1D, request);
            footZnxService.sendZnx(t.getQd1(), t.getQd2(), "请确认热身赛比赛结果",
                    null, MYVIEW, request);
        }
        int result = super.save(t, request);
        processQuartzTask(t, this);
        return result;
    }

    /**
     * 处理定时任务 两个小时后自动确认报分
     *
     * @param footBfinfo        报分实体类
     * @param footBfinfoService 报分服务类
     */
    private void processQuartzTask(FootBfinfo footBfinfo, FootBfinfoServiceImpl footBfinfoService) {
        if (!footBfinfo.getBflx().equals(BFLX.TOP)) {
            Map<String, Object> mapParams = new HashMap<>();
            mapParams.put(Constants.ID, footBfinfo.getId());
//            Date date = DateUtils.addHours(new Date(), 2);
            Date date = DateUtils.addSecond(new Date(), 60);

            //任务名称
            String name = UUID.randomUUID().toString();
            //任务所属分组
            String group = AutoBfJob.class.getName();
            CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(DateUtils.getCron(date));
            //创建任务
            JobDetail jobDetail = JobBuilder.newJob(AutoBfJob.class).withIdentity(name, group).build();
            jobDetail.getJobDataMap().put("paramMap", mapParams);
            //创建任务触发器
            Trigger trigger = TriggerBuilder.newTrigger().withIdentity(name, group).withSchedule(scheduleBuilder).build();
            //将触发器与任务绑定到调度器内
            try {
                scheduler.scheduleJob(jobDetail, trigger);
                if(scheduler.isShutdown()){
                    scheduler.start();
                }
            } catch (SchedulerException e) {
                log.error(e.getMessage());
            }
            log.info("定时任务已经执行");
        }
    }

    /**
     * 找到可以报分的用户，根据赛季信息和报分类型
     *
     * @param user 用户实体类
     * @param sj   赛季实体类
     * @param type 类型
     * @return 用户列表
     */
    @Override
    @SystemServiceLog(description = "找到可以报分的用户，根据赛季信息和报分类型")
    public List<FootUser> findCanBfUser(FootUser user, FootSj sj, Integer type) {
        List<FootUser> list = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        map.put("sj", sj.getId());
        if (type != null) {
            map.put("bflx", BFLX.values()[type]);
        }
        map.put("bothQd", user.getId());
        List<FootBfinfo> bfList = footBfinfoMapper.findByMap(map);
        if (bfList != null && !bfList.isEmpty()) {
            for (FootBfinfo bf : bfList) {
                if (bf.getQd1().equals(user.getId())) {
                    list.add(footUserService.get(bf.getQd2()));
                } else {
                    list.add(footUserService.get(bf.getQd1()));
                }
            }
        }
        return list;
    }

    /**
     * 根据用户主键和赛季来获取用户报分信息
     *
     * @param userId 用户主键
     * @param sj     赛季主键
     * @return 用户报分信息列表
     */
    @Override
    @SystemServiceLog(description = "根据用户主键和赛季来获取用户报分信息")
    public List<FootBfinfo> getSubmitData(Long userId, Long sj) {
        Map<String, Object> map = new HashMap<>();
        map.put("sj", sj);
        map.put("bflx", BFLX.NORMAL);
        map.put("bfzt", BFZT.HAVE);
        map.put("bothQd", userId);
        return footBfinfoMapper.findByMap(map);
    }

    /**
     * 根据用户主键来获取友谊赛报分信息
     *
     * @param userId 用户主键
     * @return 用户报分信息列表
     */
    @Override
    @SystemServiceLog(description = "根据用户主键来获取友谊赛报分信息")
    public List<FootBfinfo> findYysByUserId(Long userId) {
        Map<String, Object> map = new HashMap<>();
        map.put("bflx", BFLX.HOTBODY);
        map.put("bothQd", userId);
        return footBfinfoMapper.findByMap(map);
    }

    /**
     * 根据用户主键和任务数，查询对应已经完成的任务数
     *
     * @param userId     用户主键
     * @param missionnum 任务数量
     * @return 已经完成的任务数
     */
    @Override
    @SystemServiceLog(description = "根据用户主键和任务数，查询对应已经完成的任务数")
    public Integer countMissionNumByUserId(Long userId, int missionnum) {
        FootSj sj = footSjService.get(footSjService.getSj());
        Date date = new Date();
        Date startTime = DateUtils.processWithStartOrEnd(date, true);
        Date endTime = DateUtils.processWithStartOrEnd(date, false);
        BFLX bflx;
        if (missionnum == 1) {
            if (sj.getSjzt().equals(SJZT.NORMAL)) {
                bflx = BFLX.NORMAL;
            } else {
                bflx = BFLX.GRID;
            }
        } else {
            bflx = BFLX.HOTBODY;
        }
        Map<String, Object> map = new HashMap<>();
        map.put("sj", sj.getId());
        map.put("startTime", startTime);
        map.put("endTime", endTime);
        map.put("bflx", bflx);
        map.put("bothQd", userId);
        map.put("bfzt", BFZT.HAVE);
        return footBfinfoMapper.findByMap(map).size();
    }

    /**
     * 根据用户主键和报分类型查是否可以报分
     *
     * @param userId 用户主键
     * @param bflx   报分类型
     * @return 成功或失败
     */
    @Override
    @SystemServiceLog(description = "根据用户主键和报分类型查是否可以报分")
    public boolean isGoOnBf(Long userId, BFLX bflx) {
        Map<String, Object> map = new HashMap<>();
        map.put("sj", footSjService.getSj());
        map.put("bflx", bflx);
        map.put("bothQd", userId);
        if (bflx.equals(BFLX.GRID)) {
            Date date = new Date();
            map.put("startTime", DateUtils.processWithStartOrEnd(date, true));
            map.put("endTime", DateUtils.processWithStartOrEnd(date, false));
            List<FootBfinfo> list = footBfinfoMapper.findByMap(map);
            return list.size() < 2;
        } else {
            List<FootBfinfo> list = footBfinfoMapper.findByMap(map);
            return list.size() < 30;
        }
    }

    /**
     * 根据报分记录查常规赛2场限制
     *
     * @param t 报分实体类
     * @return 是否成功
     */
    @Override
    @SystemServiceLog(description = "根据报分记录查常规赛2场限制")
    public boolean isGoOnBf(FootBfinfo t) {
        Map<String, Object> map = new HashMap<>();
        map.put("sj", footSjService.getSj());
        map.put("bflx", BFLX.NORMAL);
        map.put("qd1", t.getQd1());
        map.put("qd2", t.getQd2());
        map.put("isAnd", true);
        List<FootBfinfo> list = footBfinfoMapper.findByMap(map);
        return list.size() < 2;
    }

    /**
     * 根据条件查询报分的记录列表
     *
     * @param footBfinfoSearchForm 条件
     * @return 列表
     */
    @Override
    @SystemServiceLog(description = "根据条件查询报分的记录列表")
    public List<FootBfinfo> findall(FootBfinfoSearchForm footBfinfoSearchForm) {
        return footBfinfoMapper.findall(footBfinfoSearchForm);
    }

    /**
     * 根据主键获取记录
     *
     * @param id 主键
     * @return 记录
     */
    @Override
    @SystemServiceLog(description = "根据报分主键查询报分记录")
    public FootBfinfo get(Serializable id) {
        return footBfinfoMapper.findById(id);
    }

    /**
     * 根据条件查询报分的记录列表
     *
     * @param entityname           实体类名
     * @param map                  参数
     * @param footBfinfoSearchForm 条件
     */
    @Override
    @SystemServiceLog(description = "根据条件查询报分的记录列表")
    public void search(String entityname, Model map, FootBfinfoSearchForm footBfinfoSearchForm) {
        map.addAttribute(String.format(Constants.FORMNAME, entityname), footBfinfoSearchForm);
        Page<FootBfinfo> page = PageHelper.startPage(footBfinfoSearchForm.getPageIndex(), footBfinfoSearchForm.getPageSize());
        List<FootBfinfo> list = this.findall(footBfinfoSearchForm);
        map.addAttribute(String.format(Constants.LISTENTITY, entityname), list);
        map.addAttribute(Constants.PI, page.toPageInfo());
    }

    /**
     * 删除所有
     *
     * @param footBfinfoSearchForm 条件
     * @param request              请求
     * @return 类型
     */
    @Override
    @SystemServiceLog(description = "根据条件删除所有报分的记录列表")
    public int deleteAll(FootBfinfoSearchForm footBfinfoSearchForm, HttpServletRequest request) {
        int type = 0;
        if (footBfinfoSearchForm.getSelectIds() != null) {
            String[] ids = footBfinfoSearchForm.getSelectIds().split(Constants.COMMA);
            for (String id : ids) {
                FootBfinfo bf = footBfinfoDao.selectByPrimaryKey(Long.parseLong(id));
                this.delete(Long.parseLong(id), request);
                type = bf.getBflx().ordinal();
            }
        }
        return type;
    }

    /**
     * 添加报分记录
     *
     * @param user    用户
     * @param map     参数
     * @param type    类型
     * @param request 请求
     */
    @Override
    @SystemServiceLog(description = "添加报分记录")
    public String add(FootUser user, Model map, Integer type, HttpServletRequest request) {
        Long sjId = footSjService.getSj();
        FootBfinfo bf = new FootBfinfo();
        bf.setQd1(user.getId());
        bf.setQd1Name(user.getNike());
        bf.setBflx(BFLX.values()[type]);
        processAddType(bf, map, sjId);
        bf.setBfzt(BFZT.NOT);
        bf.setSj(sjId);

        boolean canGoOn = false;
        if (type.equals(5)) {
            //天梯赛 获取符合条件的战队并随机取一个
            FootTeam team = footUserPersonService.getRandomTeam(user);
            if (null != team) {
                bf.setQd2(team.getUserId());
                bf.setQd2Name(team.getUserName());
                bf.setBfzt(BFZT.HAVE);
                String result = footTtService.winner(user.getId(), team.getUserId(), request);
                if (result.contains(":")) {
                    String[] res = result.split(":");
                    bf.setJq1(Integer.parseInt(res[0]));
                    bf.setJq2(Integer.parseInt(res[1]));
                    super.save(bf, request);
                    footUserPersonService.autoDeletePerson(bf.getQd1(), request);
                    footTtService.addEncourage(bf, request);
                    footZnxService.sendZnx(footUserService.getAdminUserid(), bf.getQd1(), "查看天梯赛结果", null,
                            MYVIEW, request);
                    canGoOn = true;
                } else {
                    canGoOn = false;
                }
            }
        }
        map.addAttribute("footBfinfo", bf);
        return processOpenPage(bf, user, canGoOn, request, map);
    }

    private void processAddType(FootBfinfo bf, Model map, Long sjId) {
        if (bf.getBflx().equals(BFLX.NORMAL)) {
            map.addAttribute("qdList", footClubService.getScoreboard(false, sjId));
        } else if (bf.getBflx().equals(BFLX.GRID)) {
            map.addAttribute("qdList", footRankService.getScoreboard());
        } else if (bf.getBflx().equals(BFLX.TOP)) {
            map.addAttribute("qdList", footTtService.getScoreboard());
        } else if (bf.getBflx().equals(BFLX.HOTBODY)) {
            FootYysSearchForm footYysSearchForm = new FootYysSearchForm();
            map.addAttribute("qdList", footYysService.findall(footYysSearchForm));
        }
    }

    /**
     * 处理打开页面
     *
     * @param bf      报分实体类
     * @param user    用户实体类
     * @param canGoOn 是否可以继续报分
     * @param request 请求
     * @param map     参数
     * @return 页面
     */
    private String processOpenPage(FootBfinfo bf, FootUser user, boolean canGoOn, HttpServletRequest request, Model map) {
        if (bf.getBflx().equals(BFLX.NORMAL)) {
            map.addAttribute(CANGOON, this.isGoOnBf(user.getId(), bf.getBflx()));
            map.addAttribute(ZHUTEAM, footUserPersonService.findQd(bf, true, request));
            return "hy/bf/footBfinfo/Add";
        } else if (bf.getBflx().equals(BFLX.GRID)) {
            map.addAttribute(CANGOON, this.isGoOnBf(user.getId(), bf.getBflx()));
            map.addAttribute(ZHUTEAM, footUserPersonService.findQd(bf, true, request));
            return "hy/bf/footRankbfinfo/Add";
        } else if (bf.getBflx().equals(BFLX.TOP)) {
            map.addAttribute(POWERONE, footUserPersonService.getPower(bf.getQd1(), request));
            map.addAttribute(POWERTWO, footUserPersonService.getPower(bf.getQd2(), request));
            map.addAttribute(ZHUTEAM, footUserPersonService.findQd(bf, true, request));
            map.addAttribute(KETEAM, footUserPersonService.findQd(bf, false, request));
            map.addAttribute(CANGOON, canGoOn);
            return "hy/bf/footTtbfinfo/Add";
        } else if (bf.getBflx().equals(BFLX.HOTBODY)) {
            return "hy/bf/footYysbfinfo/Add";
        }
        return null;
    }

    /**
     * 确认报分记录
     *
     * @param footBfinfo 报分信息
     * @param request    请求
     */
    @Override
    @SystemServiceLog(description = "确认报分记录")
    public void makesure(FootBfinfo footBfinfo, HttpServletRequest request) {
        if (footBfinfo.getId() != null) {
            FootBfinfo bf = footBfinfoDao.selectByPrimaryKey(footBfinfo.getId());
            bf.setBfzt(BFZT.HAVE);
            this.updateAll(bf, request);
        }
    }

    /**
     * 返回页面
     *
     * @param footBfinfo 报分实体类
     * @param map        参数
     * @param user       用户
     * @param request    请求
     * @return 页面
     */
    @Override
    @SystemServiceLog(description = "处理报分的返回页面")
    public String processReturnPage(@Valid FootBfinfo footBfinfo, Model map, FootUser user, HttpServletRequest request) {
        if (footBfinfo.getBflx().equals(BFLX.NORMAL)) {
            map.addAttribute(CANGOON, this.isGoOnBf(user.getId(), footBfinfo.getBflx()));
            map.addAttribute(ZHUTEAM, footUserPersonService.findFootPersonByUserId(user.getId(), request));
            return "hy/bf/footBfinfo/Add";
        } else if (footBfinfo.getBflx().equals(BFLX.GRID)) {
            map.addAttribute(CANGOON, this.isGoOnBf(user.getId(), footBfinfo.getBflx()));
            map.addAttribute(ZHUTEAM, footUserPersonService.findFootPersonByUserId(user.getId(), request));
            return "hy/bf/footRankbfinfo/Add";
        } else if (footBfinfo.getBflx().equals(BFLX.TOP)) {
            map.addAttribute(CANGOON, this.isGoOnBf(user.getId(), footBfinfo.getBflx()));
            map.addAttribute(ZHUTEAM, footUserPersonService.findFootPersonByUserId(user.getId(), request));
            return "hy/bf/footTtbfinfo/Add";
        } else if (footBfinfo.getBflx().equals(BFLX.HOTBODY)) {
            return "hy/bf/footYysbfinfo/Add";
        }
        return null;
    }

    /**
     * 处理错误页面
     *
     * @param footBfinfo    实体类
     * @param bindingResult 校验
     * @param request       请求
     */
    @Override
    @SystemServiceLog(description = "处理报分的错误信息")
    public void processError(@Valid FootBfinfo footBfinfo, BindingResult bindingResult, HttpServletRequest request) {
        if (footBfinfo.getBflx().equals(BFLX.NORMAL)) {
            List<FootPerson> list = footUserPersonService.findFootPersonByUserId(footBfinfo.getQd1(), request);
            if (list.size() < 18) {
                bindingResult.rejectValue("qd1", Constants.MISFORMAT, "自己的球队未满18人，不能报分");
            }
            List<FootPerson> list2 = footUserPersonService.findFootPersonByUserId(footBfinfo.getQd2(), request);
            if (list2.size() < 18) {
                bindingResult.rejectValue("qd1", Constants.MISFORMAT, "对手的球队未满18人，不能报分");
            }
        }
    }

    /**
     * 报分的列表页选择跳转
     *
     * @param footBfinfoSearchForm 条件
     * @param isSearchPage         是否是查询页面
     * @return 页面
     */
    @Override
    @SystemServiceLog(description = "报分的列表页选择跳转")
    public String searchPage(FootBfinfoSearchForm footBfinfoSearchForm, boolean isSearchPage) {
        if (footBfinfoSearchForm.getBflx().equals(BFLX.NORMAL)) {
            return "hy/bf/footBfinfo/" + (isSearchPage ? "List" : "MyList");
        } else if (footBfinfoSearchForm.getBflx().equals(BFLX.GRID)) {
            return "hy/bf/footRankbfinfo/" + (isSearchPage ? "List" : "MyList");
        } else if (footBfinfoSearchForm.getBflx().equals(BFLX.HOTBODY)) {
            return "hy/bf/footYysbfinfo/" + (isSearchPage ? "List" : "MyList");
        } else if (footBfinfoSearchForm.getBflx().equals(BFLX.TOP)) {
            return "hy/bf/footTtbfinfo/" + (isSearchPage ? "List" : "MyList");
        }
        return null;
    }

    /**
     * 报分的查看页选择跳转
     *
     * @param id                   主键
     * @param map                  参数
     * @param request              请求
     * @param footBfinfoSearchForm 条件
     * @param isViewPage           是否是查看页面
     * @return 页面
     */
    @Override
    @SystemServiceLog(description = "报分的查看页选择跳转")
    public String view(Long id, Model map, HttpServletRequest request, FootBfinfoSearchForm footBfinfoSearchForm, boolean isViewPage) {
        FootBfinfo bf = this.get(id);
        map.addAttribute(ZHUTEAM, footUserPersonService.findQd(bf, true, request));
        map.addAttribute(KETEAM, footUserPersonService.findQd(bf, false, request));
        map.addAttribute("footBfinfo", bf);
        if (bf.getBflx().equals(BFLX.NORMAL)) {
            return "hy/bf/footBfinfo/" + (isViewPage ? "View" : "MyView");
        } else if (bf.getBflx().equals(BFLX.GRID)) {
            return "hy/bf/footRankbfinfo/" + (isViewPage ? "View" : "MyView");
        } else if (bf.getBflx().equals(BFLX.HOTBODY)) {
            return "hy/bf/footYysbfinfo/" + (isViewPage ? "View" : "MyView");
        } else if (bf.getBflx().equals(BFLX.TOP)) {
            map.addAttribute(POWERONE, footUserPersonService.getPower(bf.getQd1(), request));
            map.addAttribute(POWERTWO, footUserPersonService.getPower(bf.getQd2(), request));
            return "hy/bf/footTtbfinfo/" + (isViewPage ? "View" : "MyView");
        }
        return null;
    }

    @Override
    @SystemServiceLog(description = "查询上赛季的报分情况")
    public List<FootBfinfo> findLastSjData(Long userId) {
        Map<String, Object> map = new HashMap<>();
        map.put("sj", footSjService.getLastSj());
        map.put("bothQd", userId);
        return footBfinfoMapper.findByMap(map);
    }
}
